﻿using M_Quality.API.Application.Command.ReinspectionCommand;
using M_Quality.Repository.Interface;
using MediatR;

namespace M_Quality.API.Application.CommandHandler.ReinspectionCommandHandler
{
    /// <summary>
    /// 删除复检（单删）
    /// </summary>
    public class DeleteReinspectionCommandHandler : IRequestHandler<DeleteReinspectionCommand, int>
    {
        private readonly IReinspectionRepository _Reinspectionrepository;
        public DeleteReinspectionCommandHandler(IReinspectionRepository reinspectionrepository)
        {
            _Reinspectionrepository = reinspectionrepository;
        }
        public async Task<int> Handle(DeleteReinspectionCommand request, CancellationToken cancellationToken)
        {
            var ss = await _Reinspectionrepository.GetModelAsync(request.ReinspectionId);
            ss.IsDeleted = true;
            return await _Reinspectionrepository.UpdateAsync(ss);
        }
    }
}
